package perl.lexical.classes;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class PString extends TokenClass {

	@Override
	public Token generateToken(String lexem) {
		Pattern p = Pattern.compile("[\",\\'].*[\",\\'].*");
		Matcher m = p.matcher(lexem);
		if (m.matches()) {
			
			
			char delimeter = lexem.charAt(0);
			int i = 1;
			
			while(lexem.charAt(i) != delimeter){
				i++;
			}
			
			String result = lexem.substring(0,i+1);
			
			return new Token(className, result);
		}

		return null;
	}
	
	
	public PString() {
		className = TokenClassEnum.PSTRING;
	}
}
